package com.wedo.mall.activity.user;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.e.library.activity.EActivity;
import com.e.library.http.EApi;
import com.e.library.utils.EStack;
import com.e.library.utils.EViewUtils;
import com.e.library.widget.ETitleBar;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.wedo.mall.R;
import com.wedo.mall.adapter.SystemMessageAdapter;
import com.wedo.mall.entity.SystemMessage;
import com.wedo.mall.ptr.Pull2Refresh;

import butterknife.BindView;

public class SystemMessageActivity extends EActivity {

    @BindView(R.id.title_bar) ETitleBar title_bar;

    @BindView(R.id.tv_empty) TextView tv_empty;
    @BindView(R.id.rv_list) XRecyclerView rv_list;

    private SystemMessageAdapter systemMessageAdapter;

    private Pull2Refresh<SystemMessage> ptr;

    @Override
    protected int layout() {
        return R.layout.activity_system_message;
    }

    @Override
    protected void onActivityCreated(Bundle state) {

        rv_list.setHasFixedSize(true);
        EViewUtils.vertical(rv_list);

        ptr = new Pull2Refresh<>();

        systemMessageAdapter = new SystemMessageAdapter(this,null);
        systemMessageAdapter.listener(this);

        ptr.widget(rv_list).adapter(systemMessageAdapter).url(EApi.USER_SYSTEMMESSAGE).clazz(SystemMessage.class).emptyWidget(tv_empty).done();

        title_bar.setOnBackwarListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EStack.onBackPressed(SystemMessageActivity.this,MessageActivity.class.getName());
                defaultFinish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        EStack.onBackPressed(this,MessageActivity.class.getName());
        super.onBackPressed();
    }
}
